export default {
    namespaced: true,
    state: {
        num: 30
    },
    //取
    getters: {
        getNum: state => {
            return state.num;
        }
    },
    //同步操作
    mutations: {
        addNum: (state, payload) => {
            // Axios.get('/').then(res => {

            //     console.log("err")
            // }).catch(err => {
            //     console.log(err)
            // });

            //调用者传递增加的数量
            state.num += payload.num;


        }
    },
    //行为，异步操作后，调用mutations执行提交改变state
    actions: {
        addNumAsync(state, payload) {
            setTimeout(() => {
                //后台比例是1
                let rate = 1;
                store.commit('addNum', { num: payload.num * rate })
                    //state.num += payload.num * rate
            }, 1);
        }
    }
}